#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<string>

using namespace std;

const int N = 200, INF = 1e9 + 10;

int n, cnt;
double g[N][N];
int id[N];
int graph[N][N];
int position[N][2];
bool visited[N];
double maxv[N];

double f(int x, int y)
{
    double a = (position[x][0] - position[y][0]) * (position[x][0] - position[y][0]);
    double b = (position[x][1] - position[y][1]) * (position[x][1] - position[y][1]);
    return sqrt(a + b);
}

void init(){
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n; j ++){
            if(i == j){
                g[i][j] = 0;
            }else{
                g[i][j] = INF;
            }
        }
    }

    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n; j ++){
            if(graph[i][j] == 1){
                g[i][j] = min(g[i][j], f(i, j));
            }
        }
    }

}




void floyed(){
    for (int k = 1; k <= n; k ++){
        for (int i = 1; i <= n; i ++){
            for (int j = 1; j <= n; j ++){
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

void dfs(int x, int cnt)
{
    id[x] = cnt;
    visited[x] = true;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i] && graph[x][i] == 1)
        {
            dfs(i, cnt);
        }
    }
}

void dyeing(){
    for (int i = 1; i <= n; i ++){
        if(!visited[i]){
            cnt++;
            dfs(i, cnt);
        }
    }
}


double getans(){

    double maxnums = 0;
    double minnums = 1e9 + 10;
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n; j ++){
            if(g[i][j] > INF / 2) continue;
            maxv[i] = max(maxv[i], g[i][j]);
            maxnums = max(maxnums, maxv[i]);
        }
    }

    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n; j ++){
            if(id[i] != id[j]){
                double temp = maxv[i] + maxv[j] + f(i, j);
                minnums = min(minnums, temp);
            }
        }
    }

    return max(maxnums, minnums);
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++){
        scanf("%d%d", &position[i][0], &position[i][1]);
    }

    string sss;
    for (int i = 1; i <= n; i ++){
        cin >> sss;
        for (int j = 1; j <= n; j ++){
            graph[i][j] = sss[j - 1] - '0';
        }
    }


    init();
    floyed();
    dyeing();
    double res = getans();
    printf("%.6f", res);

    return 0;
}